package com.top.art.controller;


import com.google.gson.Gson;
import com.top.art.annotation.PermissionLimit;
import com.top.art.bo.ExaminationBO;
import com.top.art.entity.ExamDist;
import com.top.art.manager.ExamineeInfoManager;
import com.top.art.service.IExamDistService;
import com.top.art.service.IExaminationInfoService;
import com.top.art.vo.ResVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 考场信息表 前端控制器
 * </p>
 *
 * @author hjh
 * @since 2020-10-05
 */
@RestController
@RequestMapping("/examination")
public class ExaminationInfoController {

    @Autowired
    private ExamineeInfoManager examineeInfoManager;

    @Autowired
    private IExamDistService iExamDistService;

    @Autowired
    private IExaminationInfoService examinationInfoService;

    @PostMapping(value = "/distribution")
    public ResVO distribution(@RequestBody ExaminationBO bo) {
        return new ResVO<>(examineeInfoManager.distributionExamination(bo));
    }

    @GetMapping(value = "/logDistribution")
    public ResVO<Boolean> logDistribution() {
        return new ResVO<>(iExamDistService.create());
    }

    @GetMapping(value = "/queryLogDistribution")
    public ResVO<List<ExamDist>> queryLogDistribution() {
        return new ResVO<>(iExamDistService.list());
    }


    @PostMapping("/setExaminationInfo")
    @PermissionLimit(limit = false)
    public ResVO setExaminationInfo(@RequestBody ExaminationBO bo){
        return new ResVO(examinationInfoService.setExaminationInfo(bo));
    }


    public static void main(String[] args) {
        ExaminationBO bo = new ExaminationBO();
        bo.setProvinceCode("620000");
        Map<String,Integer> map = new HashMap<>();
        map.put("01",31);
        map.put("02",31);
        map.put("03",31);
        map.put("04",31);
        map.put("05",38);
        bo.setMap(map);
        System.out.println(new Gson().toJson(bo));
    }

}
